package services;

import factory.JPAFactory;
import interfaces.IFabricanteRMI;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;

import javax.persistence.EntityManager;

import valueobjects.FabricanteVO;

public class FabricanteRMIService extends UnicastRemoteObject implements IFabricanteRMI {

	public FabricanteRMIService() throws RemoteException {
		super();
	}

	@Override
	public ArrayList<FabricanteVO> obtemListaFabricantes() throws RemoteException {
		EntityManager manager = JPAFactory.getInstance().getJPAFactory()
				.createEntityManager();
		String sql = "select object(o) " + "from FabricanteVO as o";
		ArrayList<FabricanteVO> retorno = (ArrayList<FabricanteVO>) manager
				.createQuery(sql).getResultList();
		manager.close();
		return retorno;
	}
}